<?php if (!defined('SERVER_ROOT')) exit('No direct script access allowed');

class loaidonvi_Controller extends Controller {

    function __construct(){
        parent::__construct('qlcb', 'loaidonvi');
        $this->check_login();
        $this->view->template->menu_html =$this->CREATE_MENU();
        $this->view->template->nhacviec_html =$this->CREATE_NHAC_VIEC(); 
        $this->CHECK_QUYEN('qlcb', 'loaidonvi');
    }

    function main(){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $this->dsp_all_loaidonvi();
    }

    function dsp_all_loaidonvi(){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $VIEW_DATA['arr_all_loaidonvi']= $this->model->qry_all_loaidonvi();
        $this->view->render('dsp_all_loaidonvi', $VIEW_DATA);
    }
    public function dsp_single_loaidonvi($MA_LOAI_DON_VI){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $MA_LOAI_DON_VI = replace_bad_char($MA_LOAI_DON_VI);
        $VIEW_DATA['arr_single_loaidonvi'] = $this->model->qry_single_loaidonvi($MA_LOAI_DON_VI);
        $this->view->render('dsp_single_loaidonvi', $VIEW_DATA);
    }
    public function dsp_all_linhvucxuly($MA_LOAI_DON_VI){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $MA_LOAI_DON_VI  = replace_bad_char($MA_LOAI_DON_VI);
        $TEN_LOAI_DON_VI = replace_bad_char($_REQUEST['hdn_item_name']);
        $VIEW_DATA['var_maloaidonvi'] = $MA_LOAI_DON_VI;
        $VIEW_DATA['var_tenloaidonvi'] = $TEN_LOAI_DON_VI;
        $VIEW_DATA['arr_all_linhvucxuly'] = $this->model->qry_all_linhvucxuly($MA_LOAI_DON_VI);
        $this->view->render('dsp_all_linhvucxuly', $VIEW_DATA);
    }
    public function update_loaidonvi(){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $this->model->goback_url = $this->view->get_controller_url() . 'dsp_all_loaidonvi';
        $this->model->update_loaidonvi();
    }
    public function delete_loaidonvi(){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $this->model->goback_url = $this->view->get_controller_url() . 'dsp_all_loaidonvi';
        $this->model->delete_loaidonvi();
    }

    public function update_linhvucxuly()
    {
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $this->model->goback_url = $this->view->get_controller_url() . 'dsp_all_loaidonvi';
        $this->model->update_linhvucxuly();
    }
}